home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
detect2r
/
mhdock.ctl
< prev
next >
Wrap
Text File
|
1999-08-31
|
5KB
|
141 lines
VERSION 5.00
Begin VB.UserControl MHDock
Alignable = -1 'True
CanGetFocus = 0 'False
ClientHeight = 465
ClientLeft = 0
ClientTop = 0
ClientWidth = 480
InvisibleAtRuntime= -1 'True
Picture = "MHDock.ctx":0000
ScaleHeight = 465
ScaleWidth = 480
ToolboxBitmap = "MHDock.ctx":0442
End
Attribute VB_Name = "MHDock"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'Default Property Values:
Const m_def_xDock = 360
Const m_def_yDock = 360
Const m_def_DockEnabled = True
' Saved local variables
Dim seVars As seVarsType, hMem As Long
Event Moved(xDockPos As Single, yDockPos As Single)
Attribute Moved.VB_Description = "Event fires when the form is moved."
' Copy from seVars structure to locked memory
Private Sub seVarsChanged()
If hMem Then CopyMemory ByVal hMem, seVars, LenB(seVars)
End Sub
' Fired from the subclass procedure to cause a form Moved event
Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If hMem Then
X = X \ Screen.TwipsPerPixelX
Y = Y \ Screen.TwipsPerPixelY
RaiseEvent Moved(X, Y)
End If
End Sub
' Don't allow resizing during design
Private Sub UserControl_Resize()
Height = 465: Width = 480
End Sub
' Reset the WndProc if needed
Private Sub UserControl_Terminate()
On Local Error Resume Next
SetHook seVars.lParenthWnd, False, seVars.origWndProc
DeleteSetting "MHDock", "hMem", CStr(seVars.lParenthWnd)
GlobalFree hMem
End Sub
Public Property Get DockEnabled() As Boolean
Attribute DockEnabled.VB_Description = "Active docking capabilities"
DockEnabled = seVars.bDockEnabled
End Property
Public Property Let DockEnabled(ByVal New_DockEnabled As Boolean)
seVars.bDockEnabled = New_DockEnabled
Call seVarsChanged
PropertyChanged "DockEnabled"
End Property
Public Property Get xDock() As Long
Attribute xDock.VB_Description = "Horizontal docking offset in Twips."
xDock = seVars.lxDock
End Property
Public Property Let xDock(ByVal New_xDock As Long)
seVars.lxDock = New_xDock
Call seVarsChanged
PropertyChanged "xDock"
End Property
Public Property Get yDock() As Long
Attribute yDock.VB_Description = "Vertical docking offset in Twips."
yDock = seVars.lyDock
End Property
Public Property Let yDock(ByVal New_yDock As Long)
seVars.lyDock = New_yDock
Call seVarsChanged
PropertyChanged "yDock"
End Property
Private Sub UserControl_InitProperties()
seVars.lxDock = m_def_xDock
seVars.lyDock = m_def_yDock
Call seVarsChanged
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
seVars.lxDock = PropBag.ReadProperty("xDock", m_def_xDock)
seVars.lyDock = PropBag.ReadProperty("yDock", m_def_yDock)
seVars.bDockEnabled = PropBag.ReadProperty("DockEnabled", m_def_DockEnabled)
If Ambient.UserMode Then ' Run-time only
Dim h As Long, f As Object, R As RECT
' Find the parent form's hWnd
For Each f In ParentControls
If TypeOf f Is Form Then
seVars.lParenthWnd = f.hwnd
Exit For
End If
Next
If seVars.lParenthWnd = 0 Then Exit Sub
seVars.lseHwnd = hwnd
' Retrieve the parent handle and, if the window is top level, the system tray handle
seVars.lTophWnd = GetParent(seVars.lParenthWnd)
If seVars.lTophWnd = 0 Then
seVars.lTophWnd = GetDesktopWindow()
If seVars.lTrayhWnd = 0 Then seVars.lTrayhWnd = FindWindow("Shell_TrayWnd", vbNullString)
End If
' Store the original WndProc address in seVars, allocate fixed global
' memory, and copy the seVars structure to the fixed memory
seVars.origWndProc = GetWindowLong(seVars.lParenthWnd, GWL_WNDPROC)
hMem = GlobalAlloc(GPTR, LenB(seVars))
SaveSetting "MHDock", "hMem", CStr(seVars.lParenthWnd), CStr(hMem)
Call seVarsChanged
' Hook the parent WndProc
SetHook seVars.lParenthWnd, True, seVars.origWndProc
End If
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("xDock", seVars.lxDock, m_def_xDock)
Call PropBag.WriteProperty("yDock", seVars.lyDock, m_def_yDock)
Call PropBag.WriteProperty("DockEnabled", seVars.bDockEnabled, m_def_DockEnabled)
End Sub